// {
//   "id":"",
//   "name":"",
//   "size":"",
//   "artist":"",
//   "avatar":""
// }
import 'package:mybase/base/tool/db/FFDefaultSql.dart';
import 'package:mybase/base/tool/db/FFsql.dart';
import 'package:mybase/base/tool/entitylog/MyEntityLog.dart';
import 'package:mybase/base/tool/extension/FFStringExt.dart';

class TrackEntity with FFDefaultSql, FFSQlEntityDefault {
  String? size;
  String? artist;
  String? name;
  String? avatar;
  String? path;

  TrackEntity({
    this.size,
    this.artist,
    this.name,
    this.avatar,
    int? sqlid,
    this.path,
  }) {
    this.sqlid = sqlid;
  }

  TrackEntity.fromJson(Map<String, dynamic> json) {
    sqlid = MyEntityLog.handleString(json, 'sqlid').toNum().toInt();
    size = MyEntityLog.handleString(json, 'size');
    artist = MyEntityLog.handleString(json, 'artist');
    name = MyEntityLog.handleString(json, 'name');
    avatar = MyEntityLog.handleString(json, 'avatar');
    path = MyEntityLog.handleString(json, 'path');
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['sqlid'] = this.sqlid;
    data['size'] = this.size;
    data['artist'] = this.artist;
    data['name'] = this.name;
    data['avatar'] = this.avatar;
    data['path'] = this.path;
    return data;
  }

  // 1
  @override
  String getTableName() {
    return "TrackEntity";
  }

  // 2
  @override
  TrackEntity mapToEntity(Map<String, dynamic> map) {
    var entity = TrackEntity.fromJson(map);
    // 这句一定要调用
    entity.superColumn(entity, map);
    return entity;
  }
}
